﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class CountryBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an country to db
        /// </summary>
        /// <param name="country">The country.</param>
        /// <returns></returns>
        public static int Insert(Country country)
        {
            try
            {
                country.CreateAt = DateTime.Now;
                country.CreateBy = MySession.UserID;
                country.UpdateAt = null;
                country.UpdateBy = null;
                return CountryDAL.Insert(country);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="country">A country.</param>
        /// <returns></returns>
        public static bool Update(Country country)
        {
            try
            {
                country.UpdateAt = DateTime.Now;
                country.UpdateBy = MySession.UserID;
                return CountryDAL.Update(country);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="country">A country.</param>
        /// <returns></returns>
        public static bool Delete(int countryID)
        {
            try
            {
                return CountryDAL.Delete(countryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All Country
        /// </summary>
        /// <returns></returns>
        public static CountryList GetAllCountry()
        {
            try
            {
                return CountryDAL.GetAllCountry() ?? new CountryList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="countryID">The country ID.</param>
        /// <returns></returns>
        public static Country GetCountryById(int countryID)
        {
            try
            {
                return CountryDAL.GetCountryById(countryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All Country
        /// </summary>
        /// <returns></returns>
        public static CountryJoinList GetAllCountryJoin()
        {
            try
            {
                return CountryDAL.GetAllCountryJoin() ?? new CountryJoinList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="countryID">The country ID.</param>
        /// <returns></returns>
        public static CountryROD GetCountryRODById(int countryID)
        {
            try
            {
                return CountryDAL.GetCountryRODById(countryID) ?? new CountryROD();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}